home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Code Resources / PICT Display CDEF / PICT Display CDEF.c next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  3.3 KB  |  75 lines  |  [TEXT/R*ch]

  1. /*      ---------------------------------------------------------------------------------------------
  2.         PICT display CDEF         This control
  3.                                                   definition simply displays a picture in
  4.                                                   the control rectangle.  It is not a
  5.                                                   picture button CDEF, in fact it does
  6.                                                   not respond to mouse clicks at all.
  7.         
  8.         The resource ID of the PICT is given as the initial "value".
  9.         If there is a variation code other than 0, the rectangle will also
  10.         be framed, with a thickness given by the variation code.
  11.         ---------------------------------------------------------------------------------------------
  12. */
  13.  
  14.  
  15. pascal long main(
  16.         short               varcode,       // thickness of frame.
  17.         ControlHandle    cntl_h,
  18.         short               message,
  19.         long                  param )
  20. {
  21.         long           result;
  22.         Rect           bounding_box;
  23.         PicHandle        pict_h;
  24.         SignedByte       pict_state;
  25.         RgnHandle        bounds_rgn;
  26.         
  27.         result = 0;
  28.         bounding_box = (**cntl_h).contrlRect;
  29.  
  30.         switch (message)
  31.         {
  32.                  case drawCntl:
  33.                            if ((**cntl_h).contrlVis == 0)
  34.                                       break;      // nothing to draw
  35.                            
  36.                            pict_h = GetPicture( (**cntl_h).contrlValue );
  37.                            if (pict_h)
  38.                            {
  39.                                       PenNormal();
  40.                                       pict_state = HGetState( (Handle)  pict_h );
  41.                                       HNoPurge( (Handle) pict_h );
  42.                                       DrawPicture( pict_h, &bounding_box );
  43.                                       if (varcode > 0)
  44.                                       {
  45.                                                   PenSize( varcode, varcode );
  46.                                                   FrameRect( &bounding_box );
  47.                                                   PenNormal();
  48.                                       }
  49.                                       HSetState( (Handle) pict_h, pict_state );
  50.                            }
  51.                            break;
  52.  
  53.                  case testCntl:
  54.                            /*
  55.                                       We do nothing here, so that if someone
  56.                                       clicks on the control, nothing happens.
  57.                                       If you do the obvious thing, return a part
  58.                                       code if the mouse is in the bounding
  59.                                       rectangle, then clicking on the control
  60.                                       brings it to the front.  That would
  61.                                       make it impossible to use this as a
  62.                                       background picture.
  63.                            */
  64.                            break;
  65.  
  66.                  case calcCntlRgn:
  67.                            result = 1; // Tells Cntl Mgr we handle this message
  68.                  case calcCRgns:
  69.                            RectRgn( (RgnHandle) param, &bounding_box );
  70.                            break;
  71.         }
  72.         
  73.         return result;
  74. }
  75.